package com.csun.cmny.provider.service.impl;

import com.csun.cmny.base.dto.LoginAuthDto;
import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.OmcWelfareActivityMapper;
import com.csun.cmny.provider.dto.ActivityQueryDto;
import com.csun.cmny.provider.model.domain.OmcWelfareActivity;
import com.csun.cmny.provider.service.OmcWelfareActivityService;
import com.csun.cmny.provider.vo.WelfareActivityVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
@Transactional
public class OmcWelfareActivityServiceImpl extends BaseService<OmcWelfareActivity> implements OmcWelfareActivityService {

    @Resource
    private OmcWelfareActivityMapper omcWelfareActivityMapper;

    @Override
    public PageInfo queryActivitiesWithPage(ActivityQueryDto activityQueryDto, LoginAuthDto loginAuthDto) {

        activityQueryDto.setGroupId(loginAuthDto.getGroupId());
        PageHelper.startPage(activityQueryDto.getPageNum(), activityQueryDto.getPageSize());
        List<WelfareActivityVo> wfVos = omcWelfareActivityMapper.queryActivitiesWithPage(activityQueryDto);
        return new PageInfo<>(wfVos);
    }

    @Override
    public int updateById(OmcWelfareActivity omcWelfareActivity) {
        return omcWelfareActivityMapper.updateByPrimaryKey(omcWelfareActivity);
    }
}
